package persistence;

/** * 
 * @author paul
 *
 * entity holding predefined values, that are contained in other entities
 */
public class PredefinedEntry {

	private PredefinedParam param;
	private int entryId;
	private String entryValue;
	
	protected PredefinedEntry() {}
	
	protected PredefinedEntry(PredefinedParam param, int entryId, String entryValue) {
		setParam(param);
		setEntryId(entryId);
		setEntryValue(entryValue);
	}		
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + entryId;
		result = prime * result + ((param == null) ? 0 : param.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PredefinedEntry other = (PredefinedEntry) obj;
		if (entryId != other.entryId)
			return false;
		if (param == null) {
			if (other.param != null)
				return false;
		} else if (!param.equals(other.param))
			return false;
		return true;
	}
	
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Predefined Entry for Param ").append(param).append(": entryId=").append(entryId).
		append(", entryValue=").append(entryValue);
		
		return builder.toString();
	}

	public int getEntryId() {
		return entryId;
	}
	public String getEntryValue() {
		return entryValue;
	}
	public void setEntryId(int entryId) {
		this.entryId = entryId;
	}
	public void setEntryValue(String entryValue) {
		this.entryValue = entryValue;
	}
	public PredefinedParam getParam() {
		return param;
	}
	public void setParam(PredefinedParam param) {
		this.param = param;
	}	
}